package com.example.activitylifecycletent;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    public static final String TAG ="MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG,"onCreate");
        setContentView(R.layout.activity_main);
        Button startNormalActivity =(Button) findViewById(R.id.start_normal_activity);
        Button startDialogActivity =(Button) findViewById(R.id.start_dialog_activity);
        startNormalActivity.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,NormalActivity.class);
                startActivity(intent);
            }
        });
        startDialogActivity.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,DialogActivity.class);
                startActivity(intent);
    }
        });
}
/*不可变变为可见*/
@Override
protected void onStart()
{
    super.onStart();
    Log.d(TAG,"onStart");
}
/*准备交互*/
    @Override
    protected void onResume()
    {
        super.onResume();
        Log.d(TAG,"onResume");
    }
    /*准备启动或恢复另一活动*/
    @Override
    protected void onPause()
    {
        super.onPause();
        Log.d(TAG,"onPause");
    }
    /*活动完全不可见时调用*/
    @Override
    protected void onStop()
    {
        super.onStop();
        Log.d(TAG,"onStop");
    }
    /*被销毁前调用*/
    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        Log.d(TAG,"onDestroy");
    }
    /*停止状态变成运行状态*/
    @Override
    protected void onRestart()
    {
        super.onRestart();
        Log.d(TAG,"onRestart");
    }
}